package com.sylar.lelepub.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.sylar.lelepub.R;

public class DetailPubCommAdapter extends BaseAdapter {
	// private List<DetailPage> detailPages;
	private Context mContext;
	private LayoutInflater mInflater;
	private List<String> detailPages;

	public DetailPubCommAdapter(Context context) {
		mContext = context;
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public void setListPageItems(List<String> detailPages) {
		this.detailPages = detailPages;
	}

	public int getCount() {
		if (detailPages != null)
			return detailPages.size();
		return 0;
	}

	// public DetailPage getItem(int position) {
	// if(detailPages!=null )
	// return detailPages.get(position);
	// return null;
	// }

	@Override
	public String getItem(int position) {
		if (detailPages != null)
			return detailPages.get(position);
		return null;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		ImageHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.detail_pubcomm_list_item, null);
			holder = new ImageHolder();
			holder.tv_comm_nickname = (TextView) convertView.findViewById(R.id.tv_comm_nickname);
			holder.tv_comm_content = (TextView) convertView.findViewById(R.id.tv_comm_content);
			convertView.setTag(holder);
		} else {
			holder = (ImageHolder) convertView.getTag();
		}

		return convertView;
	}

	private class ImageHolder {
		public TextView tv_comm_nickname;
		public TextView tv_comm_content;
	}
}
